using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Object_Buff : MonoBehaviour
{
    private Player_Stats playerStats;
    public string buffName;
    [SerializeField] private BuffEffectData[] buffs;

    [Header("Buff Details")]
    [SerializeField] private float buffDuration = 5;

    [Header("Floaty Movement")]
    [SerializeField] private float floatSpeed = 1;
    [SerializeField] private float floatRange = 0.2f;
    private Vector2 startPosition;
    private float yOffset;
    private void Awake()
    {
        startPosition = transform.position;

    }
    private void Update()
    {
        yOffset = Mathf.Sin(Time.time * floatSpeed) * floatRange;
        transform.position = startPosition + new Vector2(0, yOffset);
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        playerStats = collision.GetComponent<Player_Stats>();
        if (playerStats == null)
            return;
        
        playerStats.AppayBuffEffect(buffs, buffDuration, buffName);
    }
}
